﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace edu.wpi.cs.Project1
{
    /// <summary>
    /// General utitlity functions for the project.
    /// </summary>
    public static class Utility
    {
        /// <summary>
        /// Translates the object to the globally defined Z position.
        /// </summary>
        /// <param name="obj">The game object to translate.</param>
        public static void TranslateToXYLayer(GameObject obj, float z)
        {
            if (obj == null)
                return;

            Vector3 pos = obj.transform.position;
            pos.z = z;
            obj.transform.position = pos;
        }

        /// <summary>
        /// Rotates the game object orthogonal to the X/Y layer, to that only
        /// Z-rotation is allowed.
        /// </summary>
        /// <param name="obj">The game object to rotate.</param>
        public static void RotateOrthogonalToXYLayer(GameObject obj)
        {
            if (obj == null)
                return;

            Quaternion eq = Quaternion.Euler(0, 0, -obj.transform.rotation.eulerAngles.z);
            obj.transform.rotation = eq;
        }
    }
}
